home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWTValHashMultiSetIterator.z / RWTValHashMultiSetIterator
Encoding:
Text File  |  2002-10-03  |  8.5 KB  |  199 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTValHashMultiSetIterator<T,H,EQ> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include<rw/tvhasht.h>
  13.  
  14.  
  15.  
  16.               RWTValHashMultiSet<T,H,EQ> m;
  17.           RWTValHashMultiSet<T,H,EQ> itr(m);
  18.  
  19. PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!!
  20.      IIIIffff yyyyoooouuuu hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee....
  21.      OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ffffoooorrrr RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhTTTTaaaabbbblllleeeeIIIItttteeeerrrraaaattttoooorrrr described in
  22.      Appendix A.
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  30.      RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr is supplied with TTTToooooooollllssss....hhhh++++++++ 7 to provide an
  31.      iterator interface to RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr that is backward
  32.      compatible with the container iterators provided in TTTToooooooollllssss....hhhh++++++++ 6.x.
  33.      Iteration over an RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeetttt is pseudorandom and dependent on the
  34.      capacity of the underlying hash table and the hash function being used.
  35.      The only useable relationship between consecutive elements is that
  36.      elements which are defined to be equivalent by the equivalence object,
  37.      EEEEQQQQ, will remain adjacent.  The current item referenced by this iterator
  38.      is undefined after construction or after a call to rrrreeeesssseeeetttt(((())))....  The iterator
  39.      becomes valid after being advanced with either a preincrement or
  40.      ooooppppeeeerrrraaaattttoooorrrr(((()))).  For both ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last
  41.      element will return a value equivalent to boolean ffffaaaallllsssseeee.  Continued
  42.      increments will return a value equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is
  43.      called.
  44.  
  45. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  46.      None
  47.  
  48. EEEExxxxaaaammmmpppplllleeee
  49.               #include<rw/tvhasht.h>
  50.  
  51.  
  52.  
  53.               #include<iostream.h>
  54.           #include<rw/cstring.h>
  55.           struct silly_h{
  56.              unsigned long operator()(const RWCString& x) const
  57.              { return x.length() * (long)x(0); }
  58.           };
  59.           int main(){
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.              RWTValHashMultiSet
  75.                <RWCString, silly_h,equal_to<RWCString> > age;
  76.              RWTValHashMultiSetIterator
  77.                <RWCString, silly_h, equal_to<RWCString > > itr(age);
  78.              age.insert("John");
  79.              age.insert("Steve");
  80.              age.insert("Mark");
  81.              age.insert("Steve");
  82.  
  83.  
  84.                  for(;itr();)
  85.  
  86.  
  87.  
  88.                    cout << itr.key() << endl;
  89.  
  90.  
  91.  
  92.                  return 0;
  93.  
  94.  
  95.  
  96.               }
  97.  
  98.  
  99.  
  100.               Program Output (not necessarily in this order)
  101.  
  102.  
  103.  
  104.               John
  105.           Steve
  106.           Mark
  107.           Steve
  108.  
  109. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  110.               RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr<<<<TTTT,,,,HHHH,,,,EEEEQQQQ>>>> (RWTValHashMultiSet<T,H,EQ>&h);
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.      Creates an iterator for the hashed multi-set hhhh.  The iterator begins in
  118.      an undefined state and must be advanced before the first element will be
  119.      accessible
  120.  
  121. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  122.               RWBoolean
  123.           ooooppppeeeerrrraaaattttoooorrrr(((())))();
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Advances sssseeeellllffff to the next element.  Returns ffffaaaallllsssseeee if the iterator has
  141.      advanced past the last item in the container and ttttrrrruuuueeee otherwise.
  142.  
  143.               RWBoolean
  144.           ooooppppeeeerrrraaaattttoooorrrr++++++++();
  145.  
  146.  
  147.      Advances sssseeeellllffff to the next element.  If the iterator has been reset or
  148.      just created sssseeeellllffff will now reference the first element.  If, before
  149.      iteration, sssseeeellllffff referenced the last value in the multi-set, sssseeeellllffff will now
  150.      reference an undefined value and ffffaaaallllsssseeee will be returned.  Otherwise, ttttrrrruuuueeee
  151.      is returned.  Note: no postincrement operator is provided.
  152.  
  153. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  154.               RWTValHashMultiSet<T,H,EQ>*
  155.           ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
  156.  
  157.  
  158.      Returns a pointer to the collection being iterated over.
  159.  
  160.               T
  161.           kkkkeeeeyyyy() const;
  162.  
  163.  
  164.      Returns the value currently referenced by self.
  165.  
  166.               void
  167.           rrrreeeesssseeeetttt();
  168.           void
  169.           rrrreeeesssseeeetttt(RWTValHashMultiSet<T,H,EQ>& h);
  170.  
  171.  
  172.      Resets the iterator so that after being advanced it will reference the
  173.      first element of the collection.  Using rrrreeeesssseeeetttt(((()))) with no argument will
  174.      reset the iterator on the current container.  Supplying a
  175.      RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeetttt to rrrreeeesssseeeetttt(((()))) will reset the iterator on that container.
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.